//
//  HomeModules.swift
//  ShopIOS
//
//  Created by Apple on 2019/7/29.
//  Copyright © 2019 Apple. All rights reserved.
//

import Foundation
import SwiftyJSON

struct mHomeModule {
    var LModules = [mLModules]()
    var page: mPage?
    
    init(json: JSON) {
        LModules = json["LModules"].arrayValue.compactMap({ mLModules(json: $0)})
        page = mPage(json: json["page"])
    }
}

struct mPage {
    
    init(json: JSON) {
    }
}

struct mContent {
    var showType: String?
    var dataset = [mDataset]()
    var space: String?
    var margin: Int = 0
    
    init(json: JSON) {
        showType = json["showType"].stringValue
        dataset = json["dataset"].arrayValue.compactMap({ mDataset(json: $0)})
        space = json["space"].stringValue
        margin = json["margin"].intValue
    }
}

struct mDataset {
    var link: String?
    var showtitle: String?
    var linkType: Int = 0
    var title: String?
    var pic: String?
    
    init(json: JSON) {
        link = json["link"].stringValue
        showtitle = json["showtitle"].stringValue
        linkType = json["linkType"].intValue
        title = json["title"].stringValue
        pic = json["pic"].stringValue
    }
}

struct mLModules {
    var dom_ctrl: String?
    var draggable: Bool = false
    var id: String?
    var content: mContent?
    var ue: String?
    var dom_conitem: String?
    var type: Int = 0
    var sort: Int = 0
    
    init(json: JSON) {
        dom_ctrl = json["dom_ctrl"].stringValue
        draggable = json["draggable"].boolValue
        id = json["id"].stringValue
        content = mContent(json: json["content"])
        ue = json["ue"].stringValue
        dom_conitem = json["dom_conitem"].stringValue
        type = json["type"].intValue
        sort = json["sort"].intValue
    }
}

